package cn.wsalix.shop.entity;

import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.FetchType;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import cn.anlaser.entity.SimpleEntity;

@Entity
@DynamicInsert
@DynamicUpdate
@Table(name = "ORIGIN")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@EntityListeners({ AuditingEntityListener.class })
@Data
@EqualsAndHashCode(exclude={"products"},callSuper = false)
@ToString(exclude = { "products"})
public class Origin extends SimpleEntity {
	/**
		 * 
		 */
	private static final long serialVersionUID = 8500867520550921062L;
	private String logo;
/*	@OneToOne(optional = false, cascade = CascadeType.MERGE)
	@JoinColumn(name = "PRODUCT_ID", referencedColumnName = "ID", unique = true)
*/	
	@OneToMany(cascade = CascadeType.MERGE, fetch = FetchType.LAZY, mappedBy = "originItem")
	private Set<Product> products;
}